<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>编辑商品信息</title>
<link rel="stylesheet" type="text/css" href="/secondhand/css/query.css" />
<script type="text/javascript" src="/secondhand/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/secondhand/js/goods.js"></script>
	<script type="text/javascript">
		$(function (){
			var params=new URLSearchParams(window.location.search);
			var goodsid=params.get("goodsid");
			if(goodsid !=null && goodsid !=""){
				//修改数据
				var url="/secondhand/queryByGoodsId.goods";
				var jsonParm={
					"goodsid":goodsid
				};
				$.post(url,jsonParm,function (data){
					var jsonObj=JSON.parse(data);
					$("#goodsId").val(jsonObj.goodsid);
					$("#userid").val(jsonObj.userid);
					$("#goodsName").val(jsonObj.goodsname);
					$("#goodsprice").val(jsonObj.goodsprice);
					$("#description").val(jsonObj.description);
				})
			}else{
				// 新增商品时自动填充当前用户ID
				$.post("/secondhand/getCurrentUserInfo.goods", function(data) {
					if(data) {
						var userInfo = JSON.parse(data);
						$("#userid").val(userInfo.userid);
					}
				});
			}
		})
	</script>
</head>
<body>
	<div id="top">·当前位置： 商品管理 -- 编辑商品信息</div>
	<form action="/secondhand/saveOne.goods">
		<table id="tab" style="margin-top: 30px; border-collapse:separate; border-spacing:0px 10px;">
			<tr>
				<td align="right">商品ID : </td>
				<td align="left">&nbsp;<input type="text" name="goodsid" id="goodsId" readonly="readonly" placeholder="商品ID自动生成"></td>
			</tr>
			<tr>
				<td align="right" style="width:40%;">卖家ID : </td>
				<td align="left">&nbsp;<input type="text" name="userid" id="userid" readonly="readonly" placeholder="卖家ID自动生成"/><span
						style="color: red"> *</span><span id="message3" style="color: red;" class="message"></span></td>
			</tr>
			<tr>
				<td align="right" style="width:40%;">商品名称 : </td>
				<td align="left">&nbsp;<input type="text" name="goodsname" id="goodsName" /><span
					style="color: red"> *</span><span id="message0" style="color: red;" class="message"></span></td>
			</tr>
			<tr>
				<td align="right" style="width:40%;">商品价格 : </td>
				<td align="left">&nbsp;<input type="text" name="goodsprice" id="goodsprice" /><span
						style="color: red"> *</span><span id="message2" style="color: red;" class="message"></span></td>
			</tr>
			<tr>
				<td align="right">商品描述 : </td>
				<td align="left">&nbsp;<textarea name="description" id="description"></textarea><span
					style="color: red"> *</span><span id="message1" style="color: red;" class="message"></span></td>
			</tr>
			<tr>
				<td colspan="2"><input style="width: 60px;" type="submit" id="submit"
					value="提交" /></td>
			</tr>
		</table>
	</form>
</body>
</html>